<template>
	<view class="p-10">
		<view class="p-b-10">
			<text class="cred  f-15">请去插件设置里配置支付参数秘钥等;</text>
		</view>

		<view class="bg-white p-20 " style="padding-bottom: 50px">

			<uni-table border stripe @selection-change="selectionData">
				<uni-tr style=" position:sticky;top: 0;z-index: 999;">

					<uni-th v-for="(item,index) in th_list" align="center" width="120">{{item.name}}</uni-th>


				</uni-tr>
				<uni-tr v-for="(vo,index) in list" :key="index">

					<uni-td align="center" v-for="(item,index1) in th_list">


						<text v-if="item.type=='text'">{{vo[item.field]}}</text>

						<image v-else-if="item.type=='image'" :src="home_url+vo[item.field]"
							style="width: 80rpx;height: 80rpx;"></image>

						<template v-else-if="item.type=='switch'">
							<view @click="on_switch_open(index,vo[item.field])">
								<banmi-switch :is_state="vo[item.field]" is_type='0'></banmi-switch>
							</view>
						</template>
						<template v-else-if="item.type=='edit'">
							<view class="t-c">
								<button @click="on_edit(index)" class="operate_button" type="primary" size="mini">
									编辑
								</button>
							</view>
						</template>




					</uni-td>





				</uni-tr>
			</uni-table>


			<edit ref="component_edit" @confirm="confirm_edit">
			</edit>

		</view>
	</view>
</template>

<script>
	import edit from './edit.vue';

	export default {
		components: {
			edit,
		},
		data() {
			return {

				th_list: [],
				find: {},
				list: [],
				total: 0,
				page: 1,
				id: 0,
				is_top_height: false,
				home_url: ''
			}
		},
		onLoad(on) {

			this.init();
		},


		methods: {
			//全选 反选
			selectionData(list) {
				console.log("list: " + JSON.stringify(list));
			},

			on_switch_open(index, val) {
				var that = this;
				var id = this.list[index]['id'];
				let requestParams = {
					id: id,
				};
				this.Http.post('/banmichaoqiangbizhi/admin/Paypaymethod/switch_open', requestParams).then(ret => {
					this.list[index]['open'] = ret.data
				})
			},
			on_edit(index) {
				this.id = this.list[index]['id'];
				this.$refs.component_edit.init(this.id)
			},
			confirm_edit() {
				if (this.id == 0) {
					this.page = 1;
				}
				this.init();

			},


			getPage(id) {
				this.page = id.current;
				this.init()
			},
			on_add() {
				this.id = 0;
				this.$refs.component_edit.init(0)
			},
			on_search() {
				this.init();
			},
			on_search_resetting() {
				this.find = {};
				this.page = 1;
				this.init();
			},
			init() {
				var that = this;
				this.find['page'] = this.page
				this.Http.post('banmichaoqiangbizhi/admin/Paypaymethod/lists', this.find).then(ret => {
					this.home_url = ret.url

					this.th_list = ret.data.th_list;

					this.list = ret.data.list;

				})
			},
		}
	}
</script>

<style>
	.operate_button {
		width: 70px;
	}

	.operate_right {
		position: sticky;
		right: 0;
		z-index: 100;
		background-color: #fff;
	}
</style>